Page({
    data: {
        Pain:[{name:'伤害性疼痛', type:'t'},
        {name:'肌肉纤维损伤',check:false, type:'q'},
        {name:'关节炎', check:false,type:'q'},
        {name:'经痛',check:false,type:'q'},
        {name:'腹痛',check:false,type:'q'},
        { name:'盆腔痛',check:false,type:'q'},
        { name:'肠易激综合征',check:false,type:'q'},
        {name:'神经性疼痛',type:'t'},
        { name:'各种神经损伤',check:false,type:'q'},
        { name:'糖尿病周围神经痛',check:false, type:'q'},
        {name:'中风后疼痛',check:false, type:'q'},
        {name:'幻肢痛', check:false,type:'q'},
        {name:'腰背痛',check:false,type:'q'},
        {name:'复杂性局部疼痛综合征',check:false,type:'q'},
        {name:'肩背痛',check:false,type:'q'},
        {name:'带状疱疹后遗神经痛', check:false,type:'q'},
        {name:'癌症治疗后遗症', check:false, type:'q'},
        {name:'伤害可塑性疼痛', type:'t'},
        {name:'纤维肌痛综合征',check:false,type:'q'},
        {name:'其他慢性原发性疼痛', check:false, type:'q'},
        {name:'其他疼痛',type:'t'},
        {name:'其他疼痛', check:false, type:'q'}],
        pain_diseases_types:[]
    },
    onshow:function(){
      wx.hideHomeButton()
    },
    onLoad: function () {
    },
    // 选择疼痛类型
    xSelect:function(e){
      let that =this
      let param = e.currentTarget.dataset
      if(this.data.pain_diseases_types.indexOf(param.value)== -1){
        that.data.pain_diseases_types.push(param.value)
        that.setData({
          [`Pain[${param.key}].check`]:true,
        })
      }else{
        let i_t = that.data.pain_diseases_types.indexOf(param.value)
        that.data.pain_diseases_types.splice(i_t,1)
        that.setData({
          [`Pain[${param.key}].check`]:false,
        })
      }
      that.setData({
        pain_diseases_types:that.data.pain_diseases_types
      })
    },
    // 保存疼痛类型
    xSub: function (){
      let that =this;
      wx.cloud.callFunction({
        name: "user",
          data: {
            action: "edit",
            formdata: {
              pain_diseases_types:that.data.pain_diseases_types
            }
          }
      }).then(res => {
        wx.switchTab({
          url: '/pages/navigation/index/index',
        })
      })
    }
})